﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.ApproveWorkflow.Models;
using Microhard.Core.DBUtility;
using System.Activities;

namespace Microhard.ApproveWorkflow.Interfaces
{
    public interface IWorkflow : IRepository<WorkflowModel>
    {
        /// <summary>
        /// 是否有未完成的流程
        /// </summary>
        /// <param name="businessID"></param>
        /// <returns></returns>
        bool HasFlow(Guid businessID);
        /// <summary>
        /// 资源是否使用工作流
        /// </summary>
        /// <param name="resourceID"></param>
        /// <returns></returns>
        ApproveFlowChat GetFlowChart(Guid resourceID, Guid operationID);
        ApproveFlowChat GetFlowChart(Guid businessID);
        /// <summary>
        /// 通过BusinessSheetID获得WFModel对象
        /// </summary>
        /// <param name="businessSheetID"></param>
        /// <returns></returns>
        WorkflowModel GetWorkFlowModel(Guid businessSheetID,Guid resID,out string realResourceKeyName);
        /// <summary>
        /// 获得审批通过的业务对象
        /// </summary>
        /// <param name="workflowInstanceID"></param>
        /// <param name="businessID"></param>
        /// <returns></returns>
        object  GetApprovedBuzModel(Guid workflowInstanceID);
        /// <summary>
        /// 发起流程
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="model"></param>
        /// <param name="wfModel"></param>
        /// <param name="busInterface"></param>
        /// <returns></returns>
        ExecutedResult Apply<T>(T model, WorkflowModel wfModel, IRepository<T> busInterface);
        /// <summary>
        /// 流程退回，重新发起申请
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        ExecutedResult ReApply(object model, Guid workflowInstanceID, WorkflowModel wfModel);
        /// <summary>
        /// 审批
        /// </summary>
        /// <param name="businessSheetID"></param>
        /// <returns></returns>
        ExecutedResult Approve<T>(T model, WorkflowModel wfModel, IRepository<T> busInterface, string busMethodName);
        /// <summary>
        /// 归档
        /// </summary>
        /// <param name="businessSheetID"></param>
        /// <returns></returns>
        ExecutedResult Complete(Guid workflowInstanceID, WorkflowModel wfModel);
        /// <summary>
        /// 用户是否对某一个activity有访问权限
        /// </summary>
        /// <param name="activityID"></param>
        /// <param name="flowChartID"></param>
        /// <param name="currentUserID"></param>
        /// <returns></returns>
        bool IsCurrentOperatorInScope(Guid activityID, Guid flowChartID, Guid currentUserID);
    }
}
